<template>
  <div>
    <h1>provide/inject</h1>
    <Son/>
  </div>
</template>
<script>
//引入子组件
import { provide, ref } from 'vue'
import Son from './components/Son.vue'
export default {
  components: {
    Son
  },
  setup(){
    const name = ref('陈尼克')
    provide('name', name) //单个声明形式
    //修改变量的方法
    const change = () => {
      name.value = '十三'
    }
    //提供给孙组件
    provide('change', change)
  }
}
</script>